using Common.Commands;
using Common.Commands.NewsLetterCommands;
using Core.Domain.Model;
using Sanelib.DataOperation;
using Sanelib.Dto;

namespace Core.Processors.NewsLetterProcessors
{
	public class DeleteNewsLetterProcessor : ICommandProcessor<DeleteNewsLetter>
	{
        private readonly IRepository<NewsLetter> _newsLetterRepository;

        public DeleteNewsLetterProcessor(IRepository<NewsLetter> newsLetterRepository)
		{
			_newsLetterRepository = newsLetterRepository;
		}

        public dynamic Process(DeleteNewsLetter command)
 		{
			var response = new WebApiResultResponse();

			var newsLetter = _newsLetterRepository.GetById(command.Id);

			_newsLetterRepository.Delete(newsLetter.Id);
			response.IsSuccess = true;

			return response;
		}
	}
}
